! Sample Fortran module for testing
module sample_module
    use iso_fortran_env, only: real64
    implicit none
    
    private
    public :: log_calculation, store_result, finalize
    public :: data_type
    
    ! Derived type definition
    type :: data_type
        real(real64) :: value
        integer :: count
    contains
        procedure :: increment => data_increment
        procedure :: get_average => data_get_average
    end type data_type
    
    ! Module variables
    type(data_type), save :: global_data
    real(real64), parameter :: PI = 3.14159265359_real64
    
contains
    
    subroutine log_calculation(operation, result)
        implicit none
        character(*), intent(in) :: operation
        real(real64), intent(in) :: result
        
        write(*,'(A,": ",F12.6)') operation, result
    end subroutine log_calculation
    
    subroutine store_result(value)
        implicit none
        real(real64), intent(in) :: value
        
        global_data%value = global_data%value + value
        global_data%count = global_data%count + 1
    end subroutine store_result
    
    subroutine finalize()
        implicit none
        real(real64) :: average
        
        average = global_data%get_average()
        write(*,'("Final average: ",F12.6)') average
    end subroutine finalize
    
    ! Type-bound procedures
    subroutine data_increment(this, amount)
        implicit none
        class(data_type), intent(inout) :: this
        real(real64), intent(in) :: amount
        
        this%value = this%value + amount
        this%count = this%count + 1
    end subroutine data_increment
    
    function data_get_average(this) result(avg)
        implicit none
        class(data_type), intent(in) :: this
        real(real64) :: avg
        
        if (this%count > 0) then
            avg = this%value / real(this%count, real64)
        else
            avg = 0.0_real64
        end if
    end function data_get_average
    
end module sample_module